package folderLogger.outputFile.formatting;

import folderLogger.OperationSettings;
import folderLogger.outputFile.FileAttributes;

public class OutputFileXml extends OutputFileAbstract {
	
	public OutputFileXml()
	{
		super();
	}
	
	@Override
	public String getHeader(String baseFolder, OperationSettings settings) {
		return printLine(String.format("<xml base=\"%s\">", baseFolder), 1);
	}

	@Override
	public String getPreFolder(String folderName, FileAttributes attributes) {
		return printLine(String.format("<Folder name=\"%s\" coverImage=\"%s\" items=\"%d\">", folderName, attributes.getImageFileName(), attributes.getItemsCount()), 1);
	}

	@Override
	public String getPostFolder(String folderName, FileAttributes attributes) {
		DecreaseFolderDepth();
		return printLine(String.format("</Folder>"), 0);
	}

	@Override
	public String getPreFile(String fileName, FileAttributes attributes) {
		return printLine(String.format("<File name=\"%s\" size=\"%d\" />", fileName, attributes.getSize()), 0);
	}

	@Override
	public String getPostFile(String fileName, FileAttributes attributes) {
		return "";
	}

	@Override
	public String getFooter() {
		return "</xml>";
	}

	@Override
	public String[] getPreProcessData() {
		//	No additional pre-data...
		return new String[] {};
	}

}
